﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XNADota.Terrain
{
    public class Modification
    {
        public string ModificationId;
        public int VariableType;
        public string ObjectId;
    }

    public class CustomUnit
    {
        public string OriginalObjectId;
        public string ChangedObjectId;
        public int ModifiedCount;
        public Modification[] Modifications;

        public string  FindReplacedId(string originalId)
        {
            if (OriginalObjectId.CompareTo(originalId) == 0)
                return ChangedObjectId;
            else
                return null;
        }
    }

    public class CustomUnitTable
    {
        public int UnitCount;
        public CustomUnit[] CustomUnits;

        public string  FindReplacedId(string originalId)
        {
            string result= null;
            for (int i = 0; i < UnitCount; i++)
            {
                result = CustomUnits[i].FindReplacedId(originalId);
                if (result != null)
                    break;
            }
            return result;
        }
    }

    public class WarCraftCustomUnit
    {
        public int Version;
        public CustomUnitTable OriginalTable;
        public CustomUnitTable ChangedTable;

        public string FindReplacedId(string originalId)
        {
            string result = null;
            result = OriginalTable.FindReplacedId(originalId);
            if (result == null)
                result = ChangedTable.FindReplacedId(originalId);
            return result;
        }
    }
}
